package com.bh.order.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bh.common.utils.DateUtils;
import com.bh.common.utils.SecurityUtils;
import com.bh.order.domain.JcInOrOutRecord;
import com.bh.order.mapper.JcInOrOutRecordMapper;
import com.bh.order.service.IJcInOrOutRecordService;
import com.bh.order.vo.JcInOrOutRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 出入库记录Service业务层处理
 * 
 * @author slx
 * @date 2023-05-30
 */

@Service
public class JcInOrOutRecordServiceImpl extends ServiceImpl<JcInOrOutRecordMapper, JcInOrOutRecord> implements IJcInOrOutRecordService
{
    @Autowired
    private JcInOrOutRecordMapper jcInOrOutRecordMapper;

    /**
     * 查询出入库记录
     * 
     * @param id 出入库记录主键
     * @return 出入库记录
     */
    @Override
    public JcInOrOutRecord selectJcInOrOutRecordById(Long id)
    {
        return jcInOrOutRecordMapper.selectById(id);
    }

    /**
     * 查询出入库记录列表
     * 
     * @param jcInOrOutRecord 出入库记录
     * @return 出入库记录
     */
    @Override
    public List<JcInOrOutRecordVo> selectJcInOrOutRecordList(JcInOrOutRecordVo jcInOrOutRecord)
    {
        return jcInOrOutRecordMapper.selectJcInOrOutRecordList(jcInOrOutRecord);
    }

    /**
     * 新增出入库记录
     * 
     * @param jcInOrOutRecord 出入库记录
     * @return 结果
     */
    @Override
    public int insertJcInOrOutRecord(JcInOrOutRecord jcInOrOutRecord)
    {
        jcInOrOutRecord.setCreateName(SecurityUtils.getUsername());
        jcInOrOutRecord.setCreateTime(DateUtils.getNowDate());
        return jcInOrOutRecordMapper.insert(jcInOrOutRecord);
    }

    /**
     * 修改出入库记录
     * 
     * @param jcInOrOutRecord 出入库记录
     * @return 结果
     */
    @Override
    public int updateJcInOrOutRecord(JcInOrOutRecord jcInOrOutRecord)
    {
        return jcInOrOutRecordMapper.updateById(jcInOrOutRecord);
    }

    /**
     * 批量删除出入库记录
     * 
     * @param ids 需要删除的出入库记录主键
     * @return 结果
     */
    @Override
    public int deleteJcInOrOutRecordByIds(Long[] ids)
    {
        return jcInOrOutRecordMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除出入库记录信息
     * 
     * @param id 出入库记录主键
     * @return 结果
     */
    @Override
    public int deleteJcInOrOutRecordById(Long id)
    {
        return jcInOrOutRecordMapper.deleteById(id);
    }
}
